package com.oracle.pojo;

import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * book
 * @author 
 */
public class Book implements Serializable {
    private Integer bid;

    private Integer cid;

    @NotBlank(message = "书名不能为空")
    private String title;

    @NotBlank(message = "作者不能为空")
    private String author;

    @DecimalMin(message = "单价大于等于1.0",value = "1.0")
    @NotNull(message = "单价不能为空")
    private BigDecimal bprice;

    @Min(message = "库存必须大于等于10",value = 10)
    @NotNull(message = "库存不能为空")
    private Integer bnum;

    private Date pubdate;

    @NotBlank(message = "出版社不能为空")
    private String publisher;

    @NotBlank(message = "简介不能为空")
    private String story;

    private String photo;

    private Integer stated;

    private String cname;

    private static final long serialVersionUID = 1L;

    public Integer getBid() {
        return bid;
    }

    public void setBid(Integer bid) {
        this.bid = bid;
    }

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public BigDecimal getBprice() {
        return bprice;
    }

    public void setBprice(BigDecimal bprice) {
        this.bprice = bprice;
    }

    public Integer getBnum() {
        return bnum;
    }

    public void setBnum(Integer bnum) {
        this.bnum = bnum;
    }

    public Date getPubdate() {
        return pubdate;
    }

    public void setPubdate(Date pubdate) {
        this.pubdate = pubdate;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public String getStory() {
        return story;
    }

    public void setStory(String story) {
        this.story = story;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public Integer getStated() {
        return stated;
    }

    public void setStated(Integer stated) {
        this.stated = stated;
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return Objects.equals(bid, book.bid) &&
                Objects.equals(cid, book.cid) &&
                Objects.equals(title, book.title) &&
                Objects.equals(author, book.author) &&
                Objects.equals(bprice, book.bprice) &&
                Objects.equals(bnum, book.bnum) &&
                Objects.equals(pubdate, book.pubdate) &&
                Objects.equals(publisher, book.publisher) &&
                Objects.equals(story, book.story) &&
                Objects.equals(photo, book.photo) &&
                Objects.equals(stated, book.stated) &&
                Objects.equals(cname, book.cname);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bid, cid, title, author, bprice, bnum, pubdate, publisher, story, photo, stated, cname);
    }

    @Override
    public String toString() {
        return "Book{" +
                "bid=" + bid +
                ", cid=" + cid +
                ", title='" + title + '\'' +
                ", author='" + author + '\'' +
                ", bprice=" + bprice +
                ", bnum=" + bnum +
                ", pubdate=" + pubdate +
                ", publisher='" + publisher + '\'' +
                ", story='" + story + '\'' +
                ", photo='" + photo + '\'' +
                ", stated=" + stated +
                ", cname='" + cname + '\'' +
                '}';
    }
}